package com.example.androidwebpj;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import com.example.androidwebpj.service.WebService;

public class MainActivity extends AppCompatActivity {

    private Intent startIntent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.btn_start_service).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startIntent = new Intent(MainActivity.this, WebService.class);
                startService(startIntent);
            }
        });
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        stopService(startIntent);
    }
}
